package rmhc.api.vk 
{
	import rmhc.api.ApiWrapper;
	import rmhc.api.dataflow.AlbumInfo;
	import rmhc.api.dataflow.PhotoInfo;
	import rmhc.api.tasks.IGetAlbums;
	import rmhc.api.tasks.IGetPhotos;
	import rmhc.gui.customTrace;
	import rmhc.gui.SupplyFunctions;
	/**
	 * ...
	 * @author mick
	 */
	public class GetPhotosTask extends VkApiTask implements IGetPhotos
	{
		private var photos:Vector.<PhotoInfo>;
		
		public function GetPhotosTask(wrapper:ApiWrapper ,uid:String, aid:String, pids:String = null)
		{
			var params:Object = {};
			if (pids != null)
				params.pids = uid;
			params.uid = uid;
			params.aid = aid;
			super( wrapper , 'photos.get' , params);
		}
		override public function parseData(result:Object):void 
		{
			//customTrace("GetAlbumsTask:parseData:" +SupplyFunctions.objectToString(result));
			photos = new Vector.<PhotoInfo>();
			for (var i:int = 0; i < result.length; i++) 
			{
				photos.push(parsePhotoInfo(result[i]));
			}
			onComplete();
		}
		public function getPhotos():Vector.<PhotoInfo> {
			if (!photos)
				throw(new Error("Error in GetPhotosTask:getPhotos. массив photos  не готов."));
			return photos;
		}
	}

}